package ai.people.netmon.userconfig.service.handle;

import ai.people.netmon.framework.domain.userconfig.entity.UserCollectConfigAccount;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 说明
 *
 * @author zhenglin
 * @since 2022/3/25
 */
public interface HandleUrlService {

     Pattern PATTERN2 = Pattern.compile("(.+)[&/]");

    /**
     * 处理url
     *
     * @param account 账户
     * @return {@link String}
     */
    String handleUrl(UserCollectConfigAccount account);

    /**
     * 第二层处理
     *
     * @param group str
     * @return {@link String}
     */
    default String handle2(String group){
        if (group.contains("/") || group.contains("&")){
            Matcher matcher1 = PATTERN2.matcher(group);
            if (matcher1.find()){
                return matcher1.group(1);
            }
        }
        return group;
    }
}
